home *** CD-ROM | disk | FTP | other *** search
Wrap
/********************************************************* * * * Hollywood Squares 2.1 (C) 1991 Barry Christiansen * * A trivia game for SKYLINE * * * * This ARexx script is freely ditributable but not * * in the Public Domain. You may use this script for * * any purpose you see fit other than that of generating * * a profit. * * * * Disclaimer: I hearby proclaim I am NOT responsible * * accountable, ammenable, answerable or liable for any * * damage this software may cause you and your children * * or you children's children. * * * * Call THE HOST * * (605) 697-5653 * * * * Rewritten for BBBBS by Richard Lee Stockton 14-Apr-91 * * * * ANSI ENHANCED VERSION BY Rick Lembrée * * * * ANSI version adapted to BBBBS by Matt English 1-13-93 * * * **********************************************************/ options results CR='0D'x CALL TIME('R') SIGNAL ON SYNTAX SIGNAL ON BREAK_C SIGNAL ON BREAK_E PARSE ARG UserName . . colorflag secs . IF secs='' THEN secs=3600 bbspath=GETCLIP('BBS_path') BBSIDENTIFY USER PARSE VAR RESULT Username From Acces . UserName = substr(Username,2,length(Username)-2) BBSIDENTIFY EMULATION PARSE VAR RESULT type . if type = "ANSI" then colorflag=1 else colorflag=0 bbsname = 'the BBS' /* The name of your BBS */ sysopname = '+ AMIGA +' /* The name the Sysop goes by */ HSData = bbspath'rexxDoors/Data/HS.Users' /* location of user data */ HSQuestions = bbspath'rexxDoors/Data/' /* location of questions file */ Qfiles= 4 /* Number of questions files available */ TotalPlays = 5 /* How many plays per day */ if ~show('L','rexxsupport.library') then do addlib('rexxsupport.library',0,-30,0) end if colorflag = 1 then do say' Colors on!'cr RED = ''; GRN = ''; YEL = ''; BLU = ''; MAG = ''; CYA = ''; BLK = ''; BAK = ''; OFF = ' ' ; BSLF = 'DB' P7='H3H';P8='9H';P9='5H';P4='3H';P5='9H';P6='5H';P1='33H';P2='39H';P3='45H' CLS = 'H';bak1 = '' P11='1H';P12='H';CLEOL='' BIGX = ''YEL' 'BSLF' X 'BSLF' '; BIGO = ''MAG' 'BSLF' O 'BSLF' ' end else do RED = ''; GRN = ''; YEL = ''; BLU = ''; MAG = ''; CYA = ''; BAK = ''; BLK = ''; OFF = ''; CLS = CR''CR P11 = CR; P12 = CR;CLEOL='';bak1= '' BIGX = ' X '; BIGO = ' O ' end UserName2 = center(UserName,26) UserWins = 0; OtherWins = 0; UserLoses = 0; OtherLoses = 0 RePlay = 0; i = random(1,999,time('S')) /* initalize random number generator */ call Intro CALL delay(100) SAY CR' Do You Need Instructions (Y/N)? ' call Hotkey if answer = 'Y' then call Instructions SAY CR' Do You Want To See Hollywood Squares User Stats (Y/N)? ' call Hotkey if answer = 'Y' then call ShowList /* Main program body follows */ MAIN: say''cls''cr CALL TRANSMIT CR''GRN'Getting questions ready, Hold on...' filenum = random(1,Qfiles) address command 'copy 'hsquestions||'Questions'||filenum' RAM:Questions' CALL OPEN('Qdata','Ram:Questions','R') i = 0 do until eof('Qdata') do j = 1 to 6 line = readln('Qdata') end i = i+1 end CALL CLOSE('Qdata') TQuestions = i-1 over = 0 call OpenThings do i = 1 to 9 SQ.i = '' end call Refresh do forever CALL checkBBS() /* select a square and check if valid */ validsquare = 0 do while validsquare = 0 squarec = '' do while squarec < '1' | answer > '9' say''P12' ' SAY ''BLU''P12' Select A Square: 'GRN call Hotkey; squarec = answer if squarec = 'R' then call Refresh end squaren = value(squarec) if SQ.squaren = '' then validsquare = 1 if validsquare = 0 then do CALL TRANSMIT ''RED'Invalid square! ' CALL delay(50) end end /* Select a random question */ CALL TRANSMIT YEL''P11'Loading question.....' RanQ = RANDOM(1,TQuestions) CALL OPEN('Qdata','Ram:Questions','R') Qcount = 1 do until eof('Qdata') if RanQ = Qcount then do Question = readln('Qdata') do i = 1 to 4 answer.i = readln('Qdata') end line = readln('Qdata') leave end else do i = 1 to 6 line = readln('Qdata') end Qcount = Qcount + 1 end CALL CLOSE('Qdata') /* Display the Question and randomize the answers */ CALL TRANSMIT ''P11''Question''OFF'' firsttime = 0 do i = 4 to 1 by -1 j = random(1,i) Pick.i = answer.j if j = 1 & firsttime = 0 then do CorrectAnswer = i firsttime = 1 end if j < i then do x = j to i-1 xx = x + 1 answer.x = answer.xx end end CALL TRANSMIT ' ' do i = 1 to 4 CALL TRANSMIT ''BLU'['i'] - 'Pick.i end Guess = '';rfrsh = 0 do while Guess < '1' | Guess > '4' say''P12' ' SAY YEL''P12'Enter Your Guess: 'BLU call Hotkey Guess = answer if Guess = 'R' then do call Refresh CALL TRANSMIT CYA''P11''Question CALL TRANSMIT ' ' do i = 1 to 4 CALL TRANSMIT YEL'['i'] - 'BLU''Pick.i end end end XO = BIGO; who = MAG'O' SQ.squaren = XO whostring = P11''GRN'Correct! 'who''BLU' Gets the Square!'CLEOL if Guess ~= CorrectAnswer then do XO = BIGX; who = YEL'X' SQ.squaren = XO whostring = P11''RED'Incorrect! 'who''BLU' Gets the Square! 'CYA'The correct answer was 'YEL''CorrectAnswer''CLEOL'' call check if win = 'yes' then do whostring = P11''RED'Incorrect! 'GRN'The Square remains open! 'CYA'The correct answer was 'YEL''CorrectAnswer''CLEOL'' SQ.squaren = ''; XO = 'null' end end CALL TRANSMIT whostring||CR CALL delay(100) if colorflag = 1 then do do i = 1 to 5 CALL TRANSMIT CLEOL end end call clear11 if colorflag = 1 then CALL TRANSMIT P7''SQ.7''P8''SQ.8''P9''SQ.9''P4''SQ.4''P5''SQ.5''P6''SQ.6''P1''SQ.1''P2''SQ.2''P3''SQ.3 else call VanillaDisplay call Check if win = 'yes' then call won if win = 'tie' then call tie if Over = 1 then leave validsquare = 0 do while validsquare = 0 rannum = RANDOM(1,9) if SQ.rannum = '' then validsquare = 1 end Both = BIGO call BestBet Both = BIGX call BestBet squaren = rannum Correct = RANDOM(1,2) if Correct = 1 then do XO = BIGX; who = YEL'X' whostring = P11''who''BLU' Gets the Square!'CLEOL SQ.squaren = XO CALL TRANSMIT P11''CYA''subword(OtherName,1,1)' Goes For #'squaren' and answers his question'GRN' CORRECTLY!' CALL delay(100) end else do XO = BIGO; who = MAG'O' whostring = P11''who''BLU' Gets the Square!'CLEOL SQ.squaren = XO CALL TRANSMIT P11''CYA''subword(OtherName,1,1)' Goes For #'squaren' and answers his question'RED' INCORRECTLY!' CALL delay(100) call check if win = 'yes' then do whostring = P11''GRN'The Square remains open!'CLEOL SQ.squaren = ''; XO = 'null' end end CALL TRANSMIT whostring CALL delay(100) call clear11 if colorflag = 1 then CALL TRANSMIT P7''SQ.7''P8''SQ.8''P9''SQ.9''P4''SQ.4''P5''SQ.5''P6''SQ.6''P1''SQ.1''P2''SQ.2''P3''SQ.3 else call VanillaDisplay call Check if win = 'yes' then call won if win = 'tie' then call tie if Over = 1 then leave end RePlay = RePlay + 1 if RePlay = TotalPlays then do CALL TRANSMIT RED''P11'You Have Used All Your Turns For This Session!' CALL delay(50) signal BYE end SAY BLU''P11'Do You Want To Play Again (Y/N)? 'GRN call Hotkey if answer = 'Y' then signal MAIN: signal BYE Refresh: if colorflag = 1 then do CALL TRANSMIT CLS CALL TRANSMIT MAG'1H HOLLYWOOD SQUARES' CALL TRANSMIT CYA'1H'bak1'#--7-----8-----9--#'off'' CALL TRANSMIT CYA'1H'bak1'| | | |'off'' CALL TRANSMIT CYA'1H'bak1'| | | |'off'' CALL TRANSMIT CYA'1H'bak1'| | | |'off'' CALL TRANSMIT CYA'1H'bak1'|--4--+--5--+--6--|'off'' CALL TRANSMIT CYA'1H'bak1'| | | |'off' 'GRN''UserName2 CALL TRANSMIT CYA'1H'bak1'| | | |'off' 'BLU'VS' CALL TRANSMIT CYA'31H'bak1'| | | |'off' 'GRN''Othername2 CALL TRANSMIT CYA'31H'bak1'|--1--+--2--+--3--|'off'' CALL TRANSMIT CYA'31H'bak1'| | | |'off'' CALL TRANSMIT CYA'31H'bak1'| | | |'off'' CALL TRANSMIT CYA'31H'bak1'| | | |'off'' CALL TRANSMIT CYA'31H'bak1'#-----------------#'off'' CALL TRANSMIT P7''SQ.7''P8''SQ.8''P9''SQ.9''P4''SQ.4''P5''SQ.5''P6''SQ.6''P1''SQ.1''P2''SQ.2''P3''SQ.3 end else call VanillaDisplay return VanillaDisplay: CALL TRANSMIT '' CALL TRANSMIT ' HOLLYWOOD SQUARES' CALL TRANSMIT ' +-----+-----+-----+' CALL TRANSMIT ' | 'substr(SQ.7,1,3,' ')' | 'substr(SQ.8,1,3,' ')' | 'substr(SQ.9,1,3,' ')' |' CALL TRANSMIT ' | 'substr(SQ.7,4,3,' ')' | 'substr(SQ.8,4,3,' ')' | 'substr(SQ.9,4,3,' ')' |' CALL TRANSMIT ' | 'substr(SQ.7,7,3,' ')' | 'substr(SQ.8,7,3,' ')' | 'substr(SQ.9,7,3,' ')' |' CALL TRANSMIT ' |-----+-----+-----+' CALL TRANSMIT ' | 'substr(SQ.4,1,3,' ')' | 'substr(SQ.5,1,3,' ')' | 'substr(SQ.6,1,3,' ')' | 'UserName2 CALL TRANSMIT ' | 'substr(SQ.4,4,3,' ')' | 'substr(SQ.5,4,3,' ')' | 'substr(SQ.6,4,3,' ')' | VS' CALL TRANSMIT ' | 'substr(SQ.4,7,3,' ')' | 'substr(SQ.5,7,3,' ')' | 'substr(SQ.6,7,3,' ')' | 'OtherName2 CALL TRANSMIT ' +-----+-----+-----+' CALL TRANSMIT ' | 'substr(SQ.1,1,3,' ')' | 'substr(SQ.2,1,3,' ')' | 'substr(SQ.3,1,3,' ')' |' CALL TRANSMIT ' | 'substr(SQ.1,4,3,' ')' | 'substr(SQ.2,4,3,' ')' | 'substr(SQ.3,4,3,' ')' |' CALL TRANSMIT ' | 'substr(SQ.1,7,3,' ')' | 'substr(SQ.2,7,3,' ')' | 'substr(SQ.3,7,3,' ')' |' CALL TRANSMIT ' +-----+-----+-----+' CALL TRANSMIT '' return Clear12: if colorflag = 1 then CALL TRANSMIT P12' ' return Clear11: if colorflag = 1 then CALL TRANSMIT P11||CLEOL return BestBet: if SQ.5 = '' then rannum = 5 if SQ.7 = Both & SQ.8 = Both & SQ.9 = '' then rannum = 9 if SQ.7 = Both & SQ.9 = Both & SQ.8 = '' then rannum = 8 if SQ.8 = Both & SQ.9 = Both & SQ.7 = '' then rannum = 7 if SQ.4 = Both & SQ.5 = Both & SQ.6 = '' then rannum = 6 if SQ.4 = Both & SQ.6 = Both & SQ.5 = '' then rannum = 5 if SQ.5 = Both & SQ.6 = Both & SQ.4 = '' then rannum = 4 if SQ.1 = Both & SQ.2 = Both & SQ.3 = '' then rannum = 3 if SQ.1 = Both & SQ.3 = Both & SQ.2 = '' then rannum = 2 if SQ.2 = Both & SQ.3 = Both & SQ.1 = '' then rannum = 1 if SQ.7 = Both & SQ.4 = Both & SQ.1 = '' then rannum = 1 if SQ.7 = Both & SQ.1 = Both & SQ.4 = '' then rannum = 4 if SQ.4 = Both & SQ.1 = Both & SQ.7 = '' then rannum = 7 if SQ.8 = Both & SQ.5 = Both & SQ.2 = '' then rannum = 2 if SQ.8 = Both & SQ.2 = Both & SQ.5 = '' then rannum = 5 if SQ.5 = Both & SQ.2 = Both & SQ.8 = '' then rannum = 8 if SQ.9 = Both & SQ.6 = Both & SQ.3 = '' then rannum = 3 if SQ.9 = Both & SQ.3 = Both & SQ.6 = '' then rannum = 6 if SQ.6 = Both & SQ.3 = Both & SQ.9 = '' then rannum = 9 if SQ.7 = Both & SQ.5 = Both & SQ.3 = '' then rannum = 3 if SQ.7 = Both & SQ.3 = Both & SQ.5 = '' then rannum = 5 if SQ.5 = Both & SQ.3 = Both & SQ.7 = '' then rannum = 7 if SQ.9 = Both & SQ.5 = Both & SQ.1 = '' then rannum = 1 if SQ.9 = Both & SQ.1 = Both & SQ.5 = '' then rannum = 5 if SQ.5 = Both & SQ.1 = Both & SQ.9 = '' then rannum = 9 return Check: win = 'no' if SQ.7 = XO & SQ.8 = XO & SQ.9 = XO then win = 'yes' if SQ.4 = XO & SQ.5 = XO & SQ.6 = XO then win = 'yes' if SQ.1 = XO & SQ.2 = XO & SQ.3 = XO then win = 'yes' if SQ.7 = XO & SQ.4 = XO & SQ.1 = XO then win = 'yes' if SQ.8 = XO & SQ.5 = XO & SQ.2 = XO then win = 'yes' if SQ.9 = XO & SQ.6 = XO & SQ.3 = XO then win = 'yes' if SQ.7 = XO & SQ.5 = XO & SQ.3 = XO then win = 'yes' if SQ.9 = XO & SQ.5 = XO & SQ.1 = XO then win = 'yes' if SQ.7 ~= '' & SQ.8 ~= '' & SQ.9 ~= '' & SQ.4 ~= '' & SQ.5 ~= '' & SQ.6 ~= '' & SQ.1 ~= '' & SQ.2 ~= '' & SQ.3 ~= '' & win = 'no' then win = 'tie' return tie: CALL TRANSMIT 'It''s A draw! Nobody wins.' CALL delay(100); CALL CLOSE('NewUserData') address command 'Delete >NIL: T:HS.Temp' Over = 1 return Won: if who = YEL'X' then do OtherWins = OtherWins + 1 UserLoses = UserLoses + 1 CALL TRANSMIT CYA''P11''CR''CR''subword(OtherName2,1,1)''GRN' WON!' CALL TRANSMIT CYA'This Makes A Grand Total Of 'YEL''UserLoses''CYA' Games You Have 'RED'LOST!'CR end else do UserWins = UserWins + 1 OtherLoses = OtherLoses + 1 CALL TRANSMIT CYA''P11''CR''CR'You 'GRN' WON'CYA' this round!' CALL TRANSMIT CYA'This Makes A Grand Total Of 'YEL''UserWins''CYA' Games You Have 'GRN'WON!'CR end call SaveIt Over = 1 return Intro: call transmit CLS call transmit GRN' 'BLU' ___ 'GRN' 'BLU' 'GRN' 'BLU' 'GRN' ___ 'BLU' ___ 'GRN' __ ' call transmit GRN' | |'BLU' | |'GRN' | 'BLU' | 'GRN' \ /'BLU' | |'GRN' | |'BLU' | |'GRN' | \ ' call transmit GRN' | |'BLU' | |'GRN' | 'BLU' | 'GRN' \ / 'BLU' | |'GRN' | |'BLU' | |'GRN' | | ' call transmit GRN' |---|'BLU' | |'GRN' | 'BLU' | 'GRN' | 'BLU' | | |'GRN' | |'BLU' | |'GRN' | | ' call transmit GRN' | |'BLU' | |'GRN' | 'BLU' | 'GRN' | 'BLU' |/ \|'GRN' | |'BLU' | |'GRN' | | ' call transmit GRN' | |'BLU' |___|'GRN' |____'BLU' |____'GRN' | 'BLU' | |'GRN' |___|'BLU' |___|'GRN' |__/ ' call transmit GRN' ____'BLU' ___ 'GRN' 'BLU' ___ 'GRN' ___ 'BLU' ____'GRN' ____' call transmit GRN' | 'BLU' | |'GRN' | |'BLU' | |'GRN' | |'BLU' | 'GRN' | ' call transmit GRN' | 'BLU' | |'GRN' | |'BLU' | |'GRN' | |'BLU' | 'GRN' | ' call transmit GRN' --- 'BLU' | |'GRN' | |'BLU' |---|'GRN' |--- 'BLU' |-- 'GRN' --- ' call transmit GRN' |'BLU' | |'GRN' | |'BLU' | |'GRN' | \ 'BLU' | 'GRN' |' call transmit GRN' ____|'BLU' |_\_|'GRN' |___|'BLU' | |'GRN' | \'BLU' |____'GRN' ____|' call transmit GRN' 'BLU' \'CR call transmit MAG' Version 2.1 ' call transmit ' Written by Barry Christiansen' call transmit ' Original by J.L. White and D.F. Duck' call delay(50) return OpenThings: Players = 0 if ~exists(HSData) then do CALL OPEN('OldUdata',HSData,'W') CALL CLOSE('OldUdata') end CALL OPEN('OldUdata',HSData,'R') do until eof('OldUdata') line = readln('OldUdata') Players = Players + 1 end CALL CLOSE('OldUdata') Players = Players - 1 if Players <= 1 then Players = 1 WhichPlayer = Random(1,Players) x = 0 CALL OPEN('OldUdata', HSData ,'R') do until eof('OldUdata') line = readln('OldUdata') x = x + 1 parse var line name ' : ' score if x = WhichPlayer then OtherName = name if OtherName = UserName then do line = readln('OldUdata') parse var line name ' : ' score OtherName = name end end CALL CLOSE('OldUdata') if OtherName = '' then do OtherName = sysopname OtherName2 = center(OtherName,26,' ') end CALL OPEN('OldUdata',HSData,'R') CALL OPEN('NewUserData','T:HS.Temp','W') do until eof('OldUdata') line = readln('OldUdata') parse var line name ' : ' score ' : ' score2 if name = UserName then do UserWins = value(score) UserLoses = value(score2) end if name = OtherName then do OtherName = name OtherName2 = center(OtherName,26,' ') OtherWins = value(score) OtherLoses = value(score2) end if line~='' & name ~= UserName & name ~= OtherName THEN CALL writeln('NewUserData',line) end CALL CLOSE('OldUdata') return ShowList: Num = 1 call HEADER CALL OPEN('OldUdata',HSData,'R') TLines = 0 do until eof('OldUdata') line = readln('OldUdata') parse var line name ' : ' score ' : ' score2 lineb = readln('OldUdata') parse var lineb bname ' : ' bscore ' : ' bscore2 if line ~= '' then CALL TRANSMIT BAK''BLK'| o | 'left(name,20)''right(score,3)' 'right(score2,3)' 'left(bname,20)' 'right(bscore,3)' 'right(bscore2,3)' | o |' TLines = TLines + 1 if TLines = 10 then do CALL TRANSMIT BAK''BLK'| o | 'BLK'| o |' CALL TRANSMIT BAK''BLK'| o |'BLU' Continued on next Page... 'BLK'| o |' CALL TRANSMIT BAK''BLK'| o | 'BLK'| o |'OFF'' call PressReturn Num = Num + 1 call Header TLines = 0 end end CALL CLOSE('OldUdata') CALL TRANSMIT '| o | | o |' CALL TRANSMIT '| o | End Of User Listing! | o |' CALL TRANSMIT '| o | | o |'OFF'' call PressReturn return HEADER: call transmit CLS call transmit BAK''BLK'| o | 'BLU'Page'Num' 'BLK'| o |' call transmit BAK''BLK'| o | 'BLU'Hollywood Squares Players 'BLK'| o |' call transmit BAK''BLK'| o | 'BLK'| o |' call transmit BAK''BLK'| o | 'MAG'Players Names Won Lost Players Names Won Lost 'BLK'| o |' call transmit BAK''BLK'| o | 'MAG'------------------- --- ---- -------------------- --- ---- 'BLK'| o |' return Instructions: call transmit CLS call transmit CYA' Welcome to Hollywood Squares. This game combines Tic Tac Toe with Trivial' call transmit 'Pursuit. The object is to get three "O" in a row. This can be horizontal,' call transmit 'vertical, or diagonal. First you select which square you wish to play for.' call transmit 'A random question will then appear. If you answer correctly you get the' call transmit 'square, if not "X" gets the square. Your opponent is selected randomly from' call transmit 'among the list of players in the game. It keeps track of how many wins and' call transmit 'loses you have. The "X" player has a 50/50 chance of answering the question' call transmit 'right. If he is wrong you get the square he tries for. The "X" player is a' call transmit 'pretty good player. He knows when to block and when to go for a win.' call transmit ' ' call transmit ' The squares on the board are numbered like a keypad:'BLU' 7 8 9' call transmit ' 4 5 6' call transmit ' 1 2 3' call transmit ' ' call transmit CYA' At any prompt you can hit "Q" to end the game and return to the bbs.' call transmit 'If while during the game, the screen gets messed up, enter "R" to refresh' call transmit 'the screen. If you''ve ever watched HollyWood Squares on TV, then you' call transmit 'should have no problems playing this game.' call PressReturn call transmit CLS''CR''CR return SaveIt: do i = 1 to 500 end CALL writeln('NewUserData',UserName' : 'UserWins' : 'UserLoses) if UserName ~= OtherName then CALL writeln('NewUserData',OtherName' : 'OtherWins' : 'OtherLoses) CALL CLOSE('NewUserData') if Loans > 0 then address command 'Copy T:HS.Temp to 'HSData address command 'Delete >NIL: T:HS.Temp' return HOTKEY: answer=readstr() if length(answer)>1 then signal HOTKEY: if answer = 'Q' then signal BYE return PressReturn: CALL TRANSMIT ' ' SAY BLU'Press 'GRN'[RETURN]'BLU' To Continue..' out=readch(STDIN) return TRANSMIT: PARSE ARG string SAY string||CR RETURN; /* Procedures for handeling Errors, Logging off and/or re-entering SKYLINE */ SYNTAX: CALL TRANSMIT 'Line:' SIGL ' Error Code:' RC CALL TRANSMIT '*SYNTAX ERROR* External program error. PLEASE notify SYSOP.' signal BYE checkBBS: IF ADDRESS()~='BAUD' THEN RETURN 0 IF TIME('E')>secs THEN SIGNAL BYE dcd IF RC=0 THEN EXIT temp=secs-TIME('E') IF temp<120 THEN SAY '*** Only' temp 'seconds left! ***'CR RETURN 0 readstr: procedure str='' out=readch(STDIN) call WRITECH(STDOUT,out) do while out~=D2C(13) if out=D2C(8) then do str=SUBSTR(str,1,LENGTH(str)-1) call WRITECH(STDOUT,' ') call WRITECH(STDOUT,out) end else str=INSERT(str,out) out=readch(STDIN) call WRITECH(STDOUT,out) end say '0D'x return(UPPER(str)) prompt: procedure parse arg str writech(STDOUT,str) return 1 /* exit back to bbs */ BYE: BREAK_C: BREAK_E: say''cls'' say' Thanks for playing!...'cr CALL TRANSMIT CR''CR'Returning to 'bbsname exit /* Hollywood_Squares.rexx */